import Mock from 'mockjs'
export default {
  getMenu: config => {
    const { username, password } = JSON.parse(config.body)
    // 先判断用户是否存在
    // 判断账号和密码是否对应
    if (username === 'admin' && password === 'admin') {
      return {
        code: 20000,
        data: {
            menu: [
              {
                path: '/home',
                name: 'home',
                label: '首页',
                icon: 's-home',
                url: 'Home.vue'
              },
              {
                path: '/mall',
                name: 'mall',
                label: '商品管理',
                icon: 'goods',
                url: 'Mall.vue'
              },
              {
                path: '/user',
                name: 'user1',
                label: '用户管理',
                icon: 'user',
                url: 'User.vue'
              },
              {
                label: '其他',
                icon: 'info',
                children: [
                  {
                    path: '/miyang1',
                    name: 'miyang1',
                    label: '米羊1',
                    icon: 'setting',
                    url: 'MiyangOne.vue'
                  },
                  {
                    path: '/miyang2',
                    name: 'miyang2',
                    label: '米羊2',
                    icon: 'setting',
                    url: 'MiyangTwo.vue'
                  }
                ]
              }
            ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else if (username === 'xiaoxiao' && password === 'xiaoxiao') {
      return {
        code: 20000,
        data: {
          menu: [
            {
              path: '/home',
              name: 'home',
              label: '首页',
              icon: 's-home',
              url: 'Home.vue'
            },
            {
              path: '/video',
              name: 'video',
              label: '商品管理',
              icon: 'video-play',
              url: 'Mall.vue'
            }
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else {
      return {
        code: -999,
        data: {
          message: '密码错误'
        }
      }
    }

  }
}